﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Security.Principal;

namespace Happy.Security.Principal
{
    /// <summary>
    /// 没有找到如何创建一个实例的 IsAuthenticated 为 false 的类型，因此开发了此类型。
    /// </summary>
    public sealed class HappyIdentity : IIdentity
    {
        /// <summary>
        /// 构造方法。
        /// </summary>
        public HappyIdentity(string name, string type)
        {
            this.Name = name;
            this.AuthenticationType = type;
            this.IsAuthenticated = true;
        }

        /// <summary>
        /// 未通过认证的实例。
        /// </summary>
        public static HappyIdentity UnAuthenticatedIdentity { get; private set; }

        static HappyIdentity()
        {
            UnAuthenticatedIdentity = new HappyIdentity(String.Empty, string.Empty)
            {
                IsAuthenticated = false
            };
        }

        /// <summary>
        /// 用户名。
        /// </summary>
        public string Name { get; private set; }

        /// <summary>
        /// 认证类型。
        /// </summary>
        public string AuthenticationType { get; private set; }

        /// <summary>
        /// 是否通过认证。
        /// </summary>
        public bool IsAuthenticated { get; private set; }
    }
}
